import request from '@/utils/request'
import { Promise } from 'jszip/lib/external'

export function login(mobile, password) {
  return request({
    url: '/sys/login',
    method: 'post',
    data: {
      mobile,
      password
    }
  })
    .then((res) => {
      const toKen = res.data.data
      localStorage.setItem('HRM_TOKEN', `Bearer ${toKen}`)
      return res
    })
}

// 新增角色
export function postUser(data) {
  return request({
    url: '/sys/user',
    method: 'post',
    data
  })
    .then(res => res.data.message)
    .catch(err => Promise.reject(err.response.data.message))
}

// 删除角色
export function deleteUser(id) {
  return request({
    url: '/sys/user/' + id,
    method: 'delete'
  })
    .then(res => res.data.message)
    .catch(err => Promise.reject(err.response.data.message))
}
